package com.chinapost.po;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * Trole entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "TROLE", schema = "WDZY")
public class Trole implements java.io.Serializable {

	// Fields

	private String cid;
	private String cname;
	private String cdesc;
	private Set<Tuser> tusers = new HashSet<Tuser>(0);
	private Set<Tmenu> tmenus = new HashSet<Tmenu>(0);
	private Set<Tresource> tresources = new HashSet<Tresource>(0);

	// Constructors

	/** default constructor */
	public Trole() {
	}

	/** minimal constructor */
	public Trole(String cid) {
		this.cid = cid;
	}

	/** full constructor */
	public Trole(String cid, String cname, String cdesc, Set<Tuser> tusers, Set<Tmenu> tmenus, Set<Tresource> tresources) {
		this.cid = cid;
		this.cname = cname;
		this.cdesc = cdesc;
		this.tusers = tusers;
		this.tmenus = tmenus;
		this.tresources = tresources;
	}

	// Property accessors
	@Id
	@Column(name = "CID", unique = true, nullable = false, length = 36)
	public String getCid() {
		return this.cid;
	}

	public void setCid(String cid) {
		this.cid = cid;
	}

	@Column(name = "CNAME", length = 100)
	public String getCname() {
		return this.cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}

	@Column(name = "CDESC", length = 200)
	public String getCdesc() {
		return this.cdesc;
	}

	public void setCdesc(String cdesc) {
		this.cdesc = cdesc;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "troles")
	public Set<Tuser> getTusers() {
		return this.tusers;
	}

	public void setTusers(Set<Tuser> tusers) {
		this.tusers = tusers;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "TROLE_TMENU", schema = "WDZY", joinColumns = { @JoinColumn(name = "TROLEID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "TMENUID", nullable = false, updatable = false) })
	public Set<Tmenu> getTmenus() {
		return this.tmenus;
	}

	public void setTmenus(Set<Tmenu> tmenus) {
		this.tmenus = tmenus;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "TROLE_TRESOURCE", schema = "WDZY", joinColumns = { @JoinColumn(name = "TROLEID", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "TRESOURCEID", updatable = false) })
	public Set<Tresource> getTresources() {
		return this.tresources;
	}

	public void setTresources(Set<Tresource> tresources) {
		this.tresources = tresources;
	}

}